<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="标题">
              <el-input v-model="query.title" placeholder="标题" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()" native-type="submit">{{ $t('common.search') }}</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">{{ $t('common.reset') }}</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <!-- <div>
            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()" v-has="'btn_add'">新增</el-button>
          </div> -->
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list">
          <el-table-column label="品牌" prop="brand" align="center" width="80">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="title" label="标题" align="left" v-if="custom.hasP('title')" width="200" />
          <el-table-column prop="content" label="图片" align="left" v-if="custom.hasP('img')">
            <template slot-scope="scope">
              <transition-group class="el-upload-list el-upload-list--picture-card" tag="ul" name="el-list">
                <li class="el-upload-list__item is-success" v-for="(file, index) in scope.row.img" :key="file.fileId">
                  <el-image :src="file.url" fit="contain" :preview-src-list="[file.url]" :ref="'image' + index"></el-image>
                </li>
              </transition-group>
            </template>
          </el-table-column>

          <el-table-column prop="createUserName" label="创建用户" width="80" align="left" v-if="custom.hasP('createUserName')" />
          <el-table-column prop="createTime" label="创建时间" align="center" v-if="custom.hasP('createTime')" width="120" :formatter="custom.tableDateTimeFormat" />
          <el-table-column label="操作" align="center" fixed="right" width="100">
            <template slot-scope="scope">
              <table-opts @edit="addOrUpdateHandle(scope.row.id)" @del="handleDel(scope.row.id)"></table-opts>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
<style lang="scss" scoped>
@import url(index.scss);
</style>
